VERSION=arm-none-eabi
CC=$(VERSION)-gcc
CP=$(VERSION)-objcopy

DIR=SYSTEM
BUILD_DIR = build

ARM-CORE= -mcpu=cortex-m3 -mthumb

CFLAGS= $(ARM_CORE) -g -o
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections



HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S


SOURCES= main.c $(DIR)/%.c
INCLUDE= $(DIR)/%.h
DEFS=

OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))

main.hex:main.elf
	$(HEX) $< $@

main.bin:main.elf
	$(BIN) $< $@

main.elf:main.o
	$(CC)

main.o:main.c
	$(CC) -c 
	
.PHONY:clean flash erase

clean:
	rm -rf


flash:
	st-flash --format ihex write main.hex


erase:
	st-flash erase
